package entity

import (
	"strconv"

	"shqsoft.cn/pasnj/base"
	"shqsoft.cn/pasnj/bi/cube"
)

//恒生理财
type INDI_FANA_SALE struct {
	ID     int      `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHMC   string   `gorm:"column:客户名称"`
	Jyrq   int      `gorm:"column:交易日期"`
	Qrrq   int      `gorm:"column:确认日期"`
	Jyje   *float64 `gorm:"column:交易金额"`
	Qrfe   *float64 `gorm:"column:确认份额"`
	Zjhm   string   `gorm:"column:证件号码;"`
	Lsh    string   `gorm:"column:流水号;"`
	Jydm   string   `gorm:"column:交易代码;"`
	Jyjgh  string   `gorm:"column:交易机构号;"`
	Gsjgh  string   `gorm:"column:归属机构号;"`
	Lx     string   `gorm:"column:类型;"`
	Cpdm   string   `gorm:"column:产品代码;"`
	Khmc   string   `gorm:"column:产品名称;"`
	Khjlbh string   `gorm:"column:客户经理工号;"`
	Khjl   string   `gorm:"column:客户经理;"`
	CUID   int      `gorm:"column:CUID"`
	YG1    string   `gorm:"-"`
	ZB1    *float64 `gorm:"-"`
	YG2    string   `gorm:"-"`
	ZB2    *float64 `gorm:"-"`
	YG3    string   `gorm:"-"`
	ZB3    *float64 `gorm:"-"`
	YG4    string   `gorm:"-"`
	ZB4    *float64 `gorm:"-"`
	YG5    string   `gorm:"-"`
	ZB5    *float64 `gorm:"-"`
}

//TableName 表名
func (INDI_FANA_SALE) TableName() string {
	return "V_INDI_FANA_SALE"
}

// AfterFind 选择男女
func (c *INDI_FANA_SALE) AfterFind() (err error) {
	var share *cube.Share
	share, err = cube.GetShare("indi_clie_divi")
	if err != nil {
		return
	}
	var diviMap map[string]float64
	diviMap, err = share.GetDivision(strconv.Itoa(c.ID))
	if err != nil {
		return
	}
	i := 0
	for k, v := range diviMap {
		val := v
		i++
		switch i {
		case 1:
			c.YG1 = k
			c.ZB1 = &val
		case 2:
			c.YG2 = k
			c.ZB2 = &val
		case 3:
			c.YG3 = k
			c.ZB3 = &val
		case 4:
			c.YG4 = k
			c.ZB4 = &val
		case 5:
			c.YG5 = k
			c.ZB5 = &val
		default:
			break
		}
	}
	return
}

//INDI_FANA_SALEEF 个人理财销售
func INDI_FANA_SALEEF() base.EntityFunc {
	return func() interface{} {
		entity := INDI_FANA_SALE{}
		return &entity
	}
}
func INDI_FANA_SALEESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []INDI_FANA_SALE
		return &entities
	}
}

func init() {
	dao := base.NewDefaultDao(INDI_FANA_SALEEF(), INDI_FANA_SALEESF(), nil)
	filter := base.DefaultFilter{
		FilterColName: "ID",
		TableName:     "T_INDI_QTZB_DIVI",
		EmidColName:   "emid",
		AcidColName:   "JLID",
		WhereCause:    "YWID=11",
	}
	dao.Fileter = &filter
	base.DaoPoolObj.Put("INDI_FANA_SALE", dao)
}
